﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
  xmlns:x="http://www.w3.org/2001/XMLSchema"
	xmlns:o="urn:schemas-microsoft-com:office:office"
  xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
  version="1.0" 
  exclude-result-prefixes="xsl msxsl ddwrt" 
  xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" 
  xmlns:asp="http://schemas.microsoft.com/ASPNET/20" 
  xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  xmlns:SharePoint="Microsoft.SharePoint.WebControls" 
  xmlns:ddwrt2="urn:frontpage:internal">
  
  <xsl:output method="html" indent="yes" />
  
  <xsl:param name="XmlDefinition" select="."/>
  <xsl:param name="Rows" select="/dsQueryResponse/Rows"/>
  
  <xsl:template match="/">
    <table cellpadding="3">
      <tr>
        <xsl:for-each select="$XmlDefinition/ViewFields/FieldRef">
          <th>
            <xsl:value-of select="@DisplayName"/>
          </th>
        </xsl:for-each>
      </tr>
      <xsl:for-each select="/dsQueryResponse/Rows/Row">
        <tr>
          <xsl:variable name="row" select="." />
          <xsl:for-each select="$XmlDefinition/ViewFields/FieldRef">
            <xsl:variable name="fieldName" select="@Name" />
            <td>
              <xsl:choose>
                <xsl:when test="$fieldName='LinkFilenameNoMenu'">
                  <xsl:value-of select="$row/@FileLeafRef"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$row/@*[name() = $fieldName]" disable-output-escaping="yes"/>
                </xsl:otherwise>
              </xsl:choose>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>
